package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherService {
    private static TeacherDao teacherdao = new TeacherDao();

    public boolean judge(Teacher teacher) {

        return teacherdao.addTeacher(teacher);
    }
        //用来查找数组中是否存在id的方法
    public boolean query(String id) {
        Teacher[] teachers = teacherdao.inquire();
        for (int i = 0; i < teachers.length; i++) {
            if (teachers[i] != null && teachers[i].getID().equals(id)) {
                //已存在学号为false
                return false;
            }
        }
        return true;
    }
    //从TeacherDao中调用数组，查看数组是否为空
    public Teacher[] watch() {
        Teacher[] teach=teacherdao.watcher();
        for (int i = 0; i < teach.length; i++) {
            if (teach[i]!=null){
                return teach;
            }
        }
        return null;
    }
    //从TeacherDao的数组中查看是否已经删除
    public boolean delete(String id) {
        boolean teach=teacherdao.delete(id);
        if (teach){
            return true;
        }else{
            return false;
        }
    }
    //查看TeacherDao数组是否已经修改完成
    public boolean change(String id, String name, String age, String birth) {
        boolean teach=teacherdao.change(id,name,age,birth);
        if (teach){
            return true;
        }else{
            return false;
        }
    }
}
